<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ContractRecord extends Model
{
    use HasFactory;

    protected $table = 'sp_contract_record';
    protected $primaryKey = 'id';
    public $timestamps = false;

    //获取合同类型
    public static function getSignType($sign_type)
    {
        $contract_sign_type = array(1 => '一人承租协议', 2 => '二人承租协议', 3 => '三人承租协议'); //合同类型：1一人承租协议  2二人承租协议  3三人承租协议
        return getValue($sign_type, $contract_sign_type);
    }

    //担保合同列表
    protected function GetGuaranteeContractList($pageSize, $where)
    {
        $select = array('cr.*', 'su.shopname');
        $data = $this
            ->from('sp_contract_record as cr')
            ->leftjoin('sp_shop_user_2 as su', 'su.member_id', 'cr.member_id')
            ->select($select)
            ->where($where)
            ->orderBy('cr.id', 'desc')
            ->paginate($pageSize);
        $data = $data ? $data->toArray() : [];
        return $data;
    }


}
